﻿using WindowsInput;

namespace AutoClickTool.Common
{
    public static class VirtualKeyCodeDic
    {
        static VirtualKeyCodeDic()
        {
            var codes = (VirtualKeyCode[])Enum.GetValues(typeof(VirtualKeyCode));
            Data = new Dictionary<string, VirtualKeyCode>();
            foreach (var code in codes)
            {
                Data.Add(code.ToString().ToUpper(), code);
            }
        }
        private static Dictionary<string, VirtualKeyCode> Data { get; }

        /// <summary>
        /// 转换键
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static VirtualKeyCode? ConvertToVirtualKeyCode(this string key)
        {
            if (Data.ContainsKey(key))
            {
                return Data[key];
            }
            return null;
        }
    }
}
